<template>
  <div class="enterpage">
    <div class="tou">
      <p class="p1">欢迎注册平安到家车主</p>
      <p class="p2">赚钱不是问题，问题是如何选择</p>
    </div>
    <div class="rull">
      <h6>
        <span></span>
        <em>车主招募条件</em>
      </h6>
      <p>1、年龄：男22到50周岁，女22到45周岁;</p>
      <p>2、驾龄：驾龄3年以上，准驾车型c2及以上；</p>
      <p>3、无暴力犯罪、吸毒、精神病记录；无酒驾、毒驾等严重交通违法事故记录；</p>
      <p>4、普通话标准、身体健康、品貌端正，具有良好的服务意识；</p>
      <p>5、三年内被吊销出租汽车驾驶员从业资格证件的记录，或三年内有重大交通责任事故的，不予注册;</p>
    </div>
    <div class="rull">
      <h6>
        <span></span>
        <em>车辆准入招募条件</em>
      </h6>
      <p>1、有车加入车辆要求10万元以上，5-7座小型汽车，车况良好，车龄6年内；</p>
      <p>2、驾驶车辆必须为注册车辆，自有车辆或获得车主许可；</p>
    </div>
    <div class="bottom">
      <p>
        点击“立即注册拿奖励”即代表已同意
        <span style="color:#FF6917" @click="btnLegalrules">法律声明和隐私政策</span>
      </p>
      <h6 @click="fillInfo" class="bottom_btn">立即注册拿奖励</h6>
    </div>
  </div>
</template>

<script>
import { Tabs, Icon, Field, InputItem, Toast, Dialog } from 'mand-mobile';
import TopBar from '@/components/TopBar';
import Loading from '@/components/loading';
import { decryptByDESModeEBC, encryptByDESModeEBC } from '@/common/encrypt';
import Utils from '@/common/pakjUtils';
import http from '@/common/http';
export default {
  components: {
    [Tabs.name]: Tabs,
    [Icon.name]: Icon,
    [TopBar.name]: TopBar,
    [Field.name]: Field,
    [Toast.name]: Toast,
    [InputItem.name]: InputItem,
  },
  data() {
    return {
      title: '司机招募条件',
    };
  },
  mounted() {
    try {
      this.setHeader(this.title);
    } catch (e) {
      console.log(e);
    }
  },
  methods: {
    // 设置头部信息
    setHeader(text) {
      /* eslint-disable */
      var os = Utils.getOSName();
      if ((os == 'Linux' || os == 'Android') && handler) {
        //  handler.setTopText(JSON.stringify(text));
      } else if ((os == 'iOS' || os == 'MacOSX') && window.webkit) {
        window.webkit.messageHandlers.setTopText.postMessage(text);
      }
    },
    btnLegalrules() {
      window.location.href = 'http://wx.padj.group/options/legalrules';
    },
    fillInfo() {
      if (this.$route.query.phone === '' || this.$route.query.code === '') {
        Dialog.alert({
          title: '提示',
          content: '请填写手机号、验证码',
          confirmText: '确定',
          onConfirm: () => {
            this.$router.push({
              name: 'signAward',
              query: {
                haveCar: this.$route.query.haveCar,
                isCity: this.$route.query.isCity,
              },
            });
          },
        });
      } else {
        if (!/^1[3456789]\d{9}$/.test(this.$route.query.phone)) {
          Toast({
            content: '手机号码格式错误',
            duration: 3000,
            hasMask: true,
          });
          return false;
        }
        if (!/^\d{6}$/.test(this.$route.query.code)) {
          Toast({
            content: '请输入6位验证码',
            duration: 3000,
            hasMask: true,
          });
          return false;
        }
        sessionStorage.clear();
        localStorage.setItem('drive_phone', this.$route.query.phone);
        var data = {
          user_phone: encryptByDESModeEBC(this.$route.query.phone),
          mobileCode: this.$route.query.code,
        };
        Loading.show();
        http.post('pakj/driver/auditResults', data).then((res) => {
          Loading.hide();
          console.log(res.data);
          if (res.data.code === '000000') {
            localStorage.setItem('tk', res.data.data.token);
            if (!res.data.data.status) {
              //  未注册
              window.location.href =
                '/intercitydriver/fillInfo?haveCar=' +
                this.$route.query.haveCar +
                '&isCity=' +
                this.$route.query.isCity +
                '&cate=' +
                this.$route.query.cate;
              // this.$router.push({
              //     path: 'fillInfo',
              //     query: {
              //         haveCar: this.$route.query.haveCar,
              //         isCity: this.$route.query.isCity
              //     }
              // });
            } else if (res.data.data.status === '0') {
              // 注册中
              this.$router.push({
                name: 'recruitwait',
              });
            } else if (res.data.data.status === '1') {
              // 注册成功
              this.$router.push({
                name: 'recruitsuccess',
              });
            } else if (res.data.data.status === '2') {
              // 注册失败
              let error = JSON.stringify(res.data.data.driverRecruitInfo);
              sessionStorage.setItem('errMsg', error);
              this.$router.push({
                name: 'recruitfalse',
                query: {
                  haveCar: this.$route.query.haveCar,
                  isCity: this.$route.query.isCity,
                  cate: this.$route.query.cate,
                },
              });
            } else if (res.data.data.status === '3') {
              // 已是用户
              Dialog.alert({
                title: '提示',
                content: '您已成功注册',
                confirmText: '确定',
                onConfirm: () => {
                  this.$router.push({
                    name: 'enterpage',
                  });
                },
              });
            }
          } else {
            Dialog.alert({
              title: '提示',
              content: res.data.msg,
              confirmText: '确定',
            });
          }
        });
      }
    },
  },
};
</script>

<style type="text" scoped>
p {
  display: block;
  margin-block-start: 0px;
  margin-block-end: 0px;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
}

h6 {
  display: block;
  font-size: 22px;
  margin-block-start: 0em;
  margin-block-end: 0em;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
  font-weight: 400;
}
.enterpage {
  background: #fff;
}
.tou {
  background: #ff6917;
  height: 180px;
  width: 100%;
  color: #fff;
}
.tou .p1 {
  font-size: 36px;
  font-weight: 600;
  padding: 40px 30px 10px 30px;
}
.tou .p2 {
  font-size: 28px;
  padding-left: 30px;
}
.rull {
  background: #fff;
}
.rull h6 {
  list-style: none;
  border-bottom: 1px solid #ccc;
  color: #333333;
  height: 80px;
}
.rull h6 em {
  font-size: 30px;
  font-weight: 400;
  font-style: normal;
  position: relative;
  bottom: 10px;
  left: 10px;
}
.rull h6 span {
  display: inline-block;
  background: #ff6917;
  height: 50%;
  width: 3px;
  margin-left: 30px;
  margin-top: 30px;
}
.rull p {
  color: #666666;
  font-size: 28px;
  line-height: 35px;
  padding: 0px 30px;
  margin-top: 20px;
}
.bottom p {
  text-align: center;
  color: #999999;
  font-size: 24px;
  margin: 30px 0px 30px 0px;
}
.bottom_btn {
  background: #ff6917;
  width: 90%;
  margin: 0 auto;
  line-height: 88px;
  height: 88px;
  font-size: 36px;
  color: #fff;
  text-align: center;
  font-weight: 400;
  border-radius: 7px;
}
</style>
